package com.xuantu.pattern.create.singleton;

import java.io.ObjectStreamException;
import java.io.Serializable;

public class SerializableSingleton extends BaseSingleton implements Serializable {

	private static SerializableSingleton INSTANCE = new SerializableSingleton();
	
	
	public static SerializableSingleton getInstance() {
		return INSTANCE;
	}
	
	/**
	 * 防止反序列化获取多个对象的漏洞。<br/>
	 * 无论是实现Serializable接口，或是Externalizable接口，当从I/O流中读取对象时，readResolve()方法都会被调用到。<br/>  
	 * 实际上就是用readResolve()中返回的对象直接替换在反序列化过程中创建的对象。  
	 * @return
	 * @throws ObjectStreamException
	 */
	private Object readResolve() throws ObjectStreamException  {
		return INSTANCE;
	}
	
	
}
